<?php
/*
* Author：鑫宇工作室
* QQ：639519801
* url：www.xinyuream.com
*/
include_once $_SERVER['DOCUMENT_ROOT'].'/func/include.php';
$user=admin_check(true);
?>
<style>
    .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
</style>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <div class="layui-form">
			<div class="layui-form-item">
                <label class="layui-form-label">会员注册</label>
                <div class="layui-input-block">
                    <input type="checkbox" <?=config('regopen')==1?'checked=""':''?> name="regopen" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
					<div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
						<em>启用</em><i></i>
					</div>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">会员换绑</label>
                <div class="layui-input-block">
                    <input type="checkbox" <?=config('lockcode')==1?'checked=""':''?> name="lockcode" lay-skin="switch" lay-filter="switchTest" lay-text="允许|禁止">
					<div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
						<em>允许</em><i></i>
					</div>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">多开登录</label>
                <div class="layui-input-block">
                    <input type="checkbox" <?=config('dklogin')==1?'checked=""':''?> name="dklogin" lay-skin="switch" lay-filter="switchTest" lay-text="允许|禁止">
					<div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
						<em>允许</em><i></i>
					</div>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">机器绑定</label>
                <div class="layui-input-block">
                    <input type="checkbox" <?=config('vcodelogin')==1?'checked=""':''?> name="vcodelogin" lay-skin="switch" lay-filter="switchTest" lay-text="启用|关闭">
					<div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch">
						<em>启用</em><i></i>
					</div>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">解绑间隔</label>
                <div class="layui-input-inline">
                    <input type="number" name="locktime" lay-verify="pass" autocomplete="off" value="<?=config('locktime')?>" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">*天内只能解绑一次</div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">注册赠送</label>
                <div class="layui-input-inline">
                    <input type="number" name="regzs" lay-verify="pass" autocomplete="off" value="<?=config('regzs')?>" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">*注册赠送分钟</div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label">邀请赠送</label>
                <div class="layui-input-inline">
                    <input type="number" name="affzs" lay-verify="pass" autocomplete="off" value="<?=config('affzs')?>" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">*邀请赠送分钟</div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="setting">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form','miniPage'], function () {
        var form = layui.form,
            layer = layui.layer,
            miniPage = layui.miniPage,
			$ = layui.$;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();
        //监听提交
        form.on('submit(setting)', function (data) {
			data.field.regopen=data.field.regopen=='on'?1:2;
			data.field.lockcode=data.field.lockcode=='on'?1:2;
			data.field.dklogin=data.field.dklogin=='on'?1:2;
			data.field.vcodelogin=data.field.vcodelogin=='on'?1:2;
		   $.post({
				url:'/admin?ac=system',
				data: data.field,
				type:'post',
				dataType:'json',
				success:function(e){
					layui.exit(e);
					if(e.code===200){
						layer.msg(e.msg,{icon: 6,time: 2000},function(){
							miniPage.refresh({});
						});
					}else{
						layer.msg(e.msg,{icon: 5,time: 2000});
					}
				},
				error: function(e){
				  layer.msg('数据异常，操作失败！',{icon: 5,time: 2000});
				  
				}
			});
            return false;
        });

    });
</script>